import React, { Component } from "react";
import { Input, Button } from 'antd';

export default class Search extends Component {

    handleEnter = () => {
        // 获取用户的输入值
        // 结构赋值连续写法 + 重命名
        const {input:{value: keyWord}} = this.keyWordElement
        console.log(keyWord)

       const {searchItem} = this.props
       searchItem(keyWord)
    }

    render() {
        return (
            <div>
               <div>
                   <span>Search Github Users</span>
               </div>
               <div className="search">
                    <Input ref={c => this.keyWordElement = c} onPressEnter={this.handleEnter} placeholder="enter the name you searh"/>
                    <Button onClick={this.handleEnter}>Search</Button>
               </div>
            </div>
        )
    }
}